
************************************************************************************************
* RD Figs. to "Public Health Policy At Scale.."
************************************************************************************************

clear 
set more off 
set matsize 8000 
cap log close 

cd "D:\Data\workdata\707116\SIDS_RDD\"

use "SIDS_analysis_final_full.dta", clear

log using "Revision1/log_files/03 RDfigs.log", replace


g dc_sids_oth = dc_sids + dc_all_other 


g 		mor1_exc_sids = mor1 - dc_sids_oth
replace mor1_exc_sids =0 if mor1==0 


g 		mor5_exc_sids = mor5 - dc_sids_oth
replace mor5_exc_sids =0 if mor5==0 


g m_high_ed = m_short + m_mid + m_long
egen dc_other_non_sids = rowmax(dc_inf  dc_neo dc_nerv dc_resp)

g  preterm = . 
replace  preterm = 1 if fullterm37==0
replace  preterm = 0 if fullterm37==1

global motherset "mage m_basic m_voc m_high m_partn m_couple  m_immigrant" 
global childset "female border birthweight LBW gage_wks fullterm37"
global outset1 "dc_sids dc_sids_oth mor1 mor5"
global outset2 "dc_pre_nat dc_cog_mal mor1_exc_sids mor5_exc_sids" 

do "Revision1/days/rdprogs_cols1_v02.do"




***FIGURE 1: BALANCE COVARS MOTHER*** 
global bin "1" 
graph set window fontface "Georgia"


rdintgraphtlim mage dif $bin  "" "Born after Dec 1991 (in months), size(5) color(black)"  ///
" " "27(0.5)29," 


graph export "Revision1/output/days/mother_age.png", replace width(1650) height(1200) 


rdintgraphtlim m_basic dif $bin  "" "Born after Dec 1991 (in months), size(5) color(black)"  ///
" " "0.2(0.05)0.4," 

graph export "Revision1/output/days/m_basic.png", replace width(1650) height(1200) 



rdintgraphtlim m_voc dif $bin "" "Born after Dec 1991 (in months), size(5) color(black)"  ///
"  " "0.35(0.05)0.5," 


graph export "Revision1/output/days/m_voc.png",replace width(1650) height(1200)

rdintgraphtlim m_high dif $bin  "" "Born after Dec 1991 (in months), size(5) color(black)"  ///
" " "0.2(0.05)0.3,"  


graph export "Revision1/output/days/m_high.png",replace width(1650) height(1200)


rdintgraphtlim m_immigrant dif $bin "" "Born after Dec 1991 (in months), size(5) color(black)"  ///
" " "0.05(0.025)0.1,"  


graph export "Revision1/output/days/m_immigrant.png",replace width(1650) height(1200)








***FIGURE 2: BALANCED COVARS CHILD***

rdintgraphtlim female  dif $bin  "" "Born after Dec 1991 (in months), size(5) color(black)" ///
" " "0.45(0.02)0.52,"


graph export "Revision1/output/days/female.png",replace width(1650) height(1200)

rdintgraphtlim border  dif $bin "" "Born after Dec 1991 (in months), size(5) color(black)" ///
" " "1.65(0.05)1.85," 


graph export "Revision1/output/days/Border.png",replace width(1650) height(1200)


rdintgraphtlim  preterm  dif $bin "" "Born after Dec 1991 (in months), size(5) color(black)" ///
"  " "0(0.05)0.1,"


graph export "Revision1/output/days/Full_term.png",replace width(1650) height(1200)

 
rdintgraphtlim LBW dif $bin    "" "Born after Dec 1991 (in months), size(5) color(black)"  ///
" " "0(0.02)0.1,"

graph export "Revision1/output/days/LBW.png",replace width(1650) height(1200)




***FIGURE 3: MAIN OUTCOMES***
rdintgraphtlim dc_sids  dif $bin  "" "Born after Dec 1991 (in months), size(5) color(black)" ///
" " "0(10)30," 


graph export "Revision1/output/days/sids.png",replace width(1650) height(1200)

rdintgraphtlim dc_sids_oth  dif $bin "" "Born after Dec 1991 (in months), size(5) color(black)"  ///
" " "0(10)50," 


graph export "Revision1/output/days/sids_oth.png",replace width(1650) height(1200)


rdintgraphtlim mor1 dif $bin   "" "Born after Dec 1991 (in months), size(5) color(black)"  ///
" "  "40(20)100,"


graph export "Revision1/output/days/mor1.png",replace width(1650) height(1200)


rdintgraphtlim mor5 dif $bin  "" "Born after Dec 1991 (in months), size(5) color(black)" ///
" " "40(20)120," 


graph export "Revision1/output/days/mor5.png",replace width(1650) height(1200)
 
 
 rdintgraphtlim mor1_exc_sids dif $bin   "" "Born after Dec 1991 (in months), size(5) color(black)"  ///
" "  "20(20)80,"


graph export "Revision1/output/days/morexc1.png",replace width(1650) height(1200)


rdintgraphtlim mor5_exc_sids dif $bin  "" "Born after Dec 1991 (in months), size(5) color(black)" ///
" " "20(20)100," 


graph export "Revision1/output/days/mor5exc.png",replace width(1650) height(1200)


log close 

 





